<template>
  <Module-box title="维保工单提醒" height="293px" bg="long1">
    <G-table
      id="wb"
      :columns="columns"
      :data="dataList"
      :fixeds="fixedList"
      :speed="3"
      hover
      height="220"
    />
  </Module-box>
</template>
<script>
import { getWorkWarrantyReminder } from "@/utils/screen";
export default {
  data() {
    return {
      columns: [
        { label: "工单ID", prop: "workID", align: "left", width: 80 },
        {
          label: "客户名称",
          align: "left",
          scroll: false,
          default: (row, column) => {
            let text;
            if (column.scroll) {
              text = row.hospitalName || "-";
            } else {
              let frist = row.hospitalName ? row.hospitalName[0] : "";
              text = frist ? frist + "*".repeat(row.hospitalName.length - 1) : "-";
            }
            return text;
          },
        },
        { label: "科室", prop: "departmentName", align: "left" },
        { label: "设备品牌", prop: "oneClassName", align: "left" },
        { label: "型号", prop: "threeClassName", align: "left" },
        { label: "下次保养时间", prop: "next", align: "left" },
        {
          label: "保养次数",
          align: "left",
          width: 100,
          default: (row) => `${row.surplus_num || 0}/${row.maintain_num || 0}`,
        },
        { label: "物流单号", prop: "logisticsNumber", align: "left" },
      ],
      dataList: [], // 数据列表
      fixedList: [], // 固定行列表
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    // 获取维保工单提醒列表
    getList() {
      getWorkWarrantyReminder().then((res) => {
        if (res && res.code == 1) {
          this.dataList = res.data || [];
          this.fixedList = res.data.filter((i) => i.environment_state == 2).splice(0, 3);
        }
      });
    },
    // 父级调用清空置顶
    clearFixed() {
      this.fixedList = [];
    },
  },
};
</script>
<style lang="scss" scoped></style>
